<!DOCTYPE html>


<html lang="zh-CN">


<head>
  <meta charset="utf-8" />
   
  <meta name="keywords" content="zesicus" />
   
  <meta name="description" content="有所感，有所记" />
  
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
  <title>
    macOS Hexo + Gitee 安装 &amp; 使用 详细攻略 |  黑森林
  </title>
  <meta name="generator" content="hexo-theme-ayer">
  
  <link rel="shortcut icon" href="/images/littleicon.png" />
  
  
<link rel="stylesheet" href="/dist/main.css">

  
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/Shen-Yu/cdn/css/remixicon.min.css">

  
<link rel="stylesheet" href="/css/custom.css">

  
  
<script src="https://cdn.jsdelivr.net/npm/pace-js@1.0.2/pace.min.js"></script>

  
  

  

<link rel="alternate" href="/atom.xml" title="黑森林" type="application/atom+xml">
</head>

</html>

<body>
  <div id="app">
    
      
    <main class="content on">
      <section class="outer">
  <article
  id="post-Mac-Hexo-Gitee-安装-使用-全记录"
  class="article article-type-post"
  itemscope
  itemprop="blogPost"
  data-scroll-reveal
>
  <div class="article-inner">
    
    <header class="article-header">
       
<h1 class="article-title sea-center" style="border-left:0" itemprop="name">
  macOS Hexo + Gitee 安装 &amp; 使用 详细攻略
</h1>
 

    </header>
     
    <div class="article-meta">
      <a href="/2020/01/18/Mac-Hexo-Gitee-%E5%AE%89%E8%A3%85-%E4%BD%BF%E7%94%A8-%E5%85%A8%E8%AE%B0%E5%BD%95/" class="article-date">
  <time datetime="2020-01-18T15:06:08.000Z" itemprop="datePublished">2020-01-18</time>
</a> 
  <div class="article-category">
    <a class="article-category-link" href="/categories/%E6%8A%80%E6%9C%AF/">技术</a>
  </div>
  
<div class="word_count">
    <span class="post-time">
        <span class="post-meta-item-icon">
            <i class="ri-quill-pen-line"></i>
            <span class="post-meta-item-text"> 字数统计:</span>
            <span class="post-count">2.8k</span>
        </span>
    </span>

    <span class="post-time">
        &nbsp; | &nbsp;
        <span class="post-meta-item-icon">
            <i class="ri-book-open-line"></i>
            <span class="post-meta-item-text"> 阅读时长≈</span>
            <span class="post-count">12 分钟</span>
        </span>
    </span>
</div>
 
    </div>
      
    <div class="tocbot"></div>




  
    <div class="article-entry" itemprop="articleBody">
       
  <p><img src="/2020/01/18/Mac-Hexo-Gitee-%E5%AE%89%E8%A3%85-%E4%BD%BF%E7%94%A8-%E5%85%A8%E8%AE%B0%E5%BD%95/cover1.jpg" alt="cover1"></p>
<p>Hexo Blog Gitee 部署记录<br>2021.01.15 更新</p>
<h3 id="Step-1-安装"><a href="#Step-1-安装" class="headerlink" title="Step 1 安装"></a>Step 1 安装</h3><h4 id="准备"><a href="#准备" class="headerlink" title="准备"></a>准备</h4><ol>
<li><p>确认已安装 <code>Git</code>，一般 macOS 已经预装好了，可以通过 <code>git --version</code> 命令来确认。 没有的话也可以通过 <code>brew install git</code> 进行安装。</p>
</li>
<li><p>安装<code>Xcode</code>，为了避免一些错误，苹果官方的开发工具我们可能也要安装一下，App Store 上搜索安装就好，接着打开它，菜单栏 <strong>Preferences -&gt; Download -&gt; Command Line Tools -&gt; Install</strong> 安装命令行工具。</p>
</li>
<li><p>确认是否已安装 <code>NPM</code>，终端运行 <code>npm --version</code>，我的版本是 6.10.3，没有的话也请使用 <code>brew install npm</code> 安装；</p>
</li>
</ol>
<a id="more"></a>

<blockquote>
<p>以上提到的 <code>brew</code> 相关命令需要借助 “Homebrew” 工具，关于此软件不多做解释，推荐 <a target="_blank" rel="noopener" href="https://zhuanlan.zhihu.com/p/111014448">Homebrew国内如何自动安装（国内地址）</a> 。</p>
</blockquote>
<h4 id="安装"><a href="#安装" class="headerlink" title="安装"></a>安装</h4><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ npm install -g hexo-cli</span><br></pre></td></tr></table></figure>
<blockquote>
<p>不推荐国内淘宝镜像源，因为该源中的 Hexo 是老版本，如需更换请使用命令 <code>npm config set registry https://registry.npm.taobao.org</code>，验证命令 <code>npm config get registry</code> 检测是否更换成功；如果想还原 npm 官方源的话，运行 <code>npm config set registry https://registry.npmjs.org</code>即可。</p>
</blockquote>
<h4 id="升级"><a href="#升级" class="headerlink" title="升级"></a>升级</h4><p>同样使用</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ npm install -g hexo-cli</span><br></pre></td></tr></table></figure>
<p>可直接更新版本。</p>
<h4 id="卸载"><a href="#卸载" class="headerlink" title="卸载"></a>卸载</h4><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">npm uninstall -g hexo-cli</span><br></pre></td></tr></table></figure>
<blockquote>
<p>若 <code>hexo</code> 仍能够执行，到目录 <code>/usr/local/lib/node_modules</code> 检查下是否存在软件包。</p>
</blockquote>
<h3 id="Step-2-使用"><a href="#Step-2-使用" class="headerlink" title="Step 2 使用"></a>Step 2 使用</h3><h4 id="准备-1"><a href="#准备-1" class="headerlink" title="准备"></a>准备</h4><ol>
<li>首先建立一个用于存放Hexo源代码的文件夹，这里我将该文件夹称为 <code>Blog</code>（以下我都直接称为 Blog 文件夹），打开终端，<code>cd</code> 到该目录下。</li>
<li>执行 <code>hexo init</code> 进行初始化，根据网络状态好坏程度，耐心等待初始化完成。</li>
<li>初始化完成后，在 Blog 目录执行 <code>hexo s</code>，等待一两秒钟会看到 “INFO  Hexo is running at <a target="_blank" rel="noopener" href="http://localhost:4000/">http://localhost:4000</a> . Press Ctrl+C to stop.”，OK已经运行好了，访问 <a target="_blank" rel="noopener" href="http://localhost:4000/">http://localhost:4000</a>，我们的博客已经初步建设好了! </li>
</ol>
<p>准备步骤结束，接下来我们开始配置码云。</p>
<h4 id="部署"><a href="#部署" class="headerlink" title="部署"></a>部署</h4><blockquote>
<p>和 Github 搭建静态页面很相似，不同的是，如果你想要以 “yourname(你的用户名).gitee.io” 的形式访问你的站点，那么你需要新建仓库的名字是 “yourname(你的用户名)” 而不是 “yourname(你的用户名).gitee.io” 了。</p>
</blockquote>
<ol>
<li><p>在Gitee新建仓库名称 “yourname(你的用户名)”。</p>
<blockquote>
<p>这里不同于 Github 的是在 “管理” 里面并没有设置静态页面的操作，而在它左边还有个按钮名称为 “服务”，我们将要在这里设置静态页面，但是空仓库的情况下是没有这个选项的。</p>
</blockquote>
</li>
<li><p>到 Blog 目录中，找到 <code>\_config.yml</code> 文件，打开它，我们需要修改几个地方，这里建议对这个文件备份，以我的文件为例：</p>
<figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># Site 这里是描述信息，按照自己的意愿修改</span></span><br><span class="line"><span class="attr">title:</span> <span class="string">你的标题</span></span><br><span class="line"><span class="attr">subtitle:</span> <span class="string">&#x27;副标题&#x27;</span></span><br><span class="line"><span class="attr">description:</span> <span class="string">&#x27;描述信息&#x27;</span></span><br><span class="line"><span class="attr">keywords:</span> <span class="string">关键词</span></span><br><span class="line"><span class="attr">author:</span> <span class="string">Sunny</span></span><br><span class="line"><span class="attr">language:</span> <span class="string">zh</span></span><br><span class="line"><span class="attr">timezone:</span> <span class="string">&#x27;Asia/Shanghai&#x27;</span></span><br><span class="line"></span><br><span class="line"><span class="comment"># URL 站点URL，示例如下</span></span><br><span class="line"><span class="attr">url:</span> <span class="string">https://zesicus.gitee.io</span></span><br><span class="line"></span><br><span class="line"><span class="comment"># Deployment 很重要，部署信息一定要填写的</span></span><br><span class="line"><span class="comment">## Docs: https://hexo.io/docs/deployment.html</span></span><br><span class="line"><span class="attr">deploy:</span></span><br><span class="line">  <span class="attr">type:</span> <span class="string">git</span></span><br><span class="line">  <span class="attr">repo:</span> <span class="string">git@gitee.com:zesicus/zesicus.git</span></span><br><span class="line">  <span class="attr">branch:</span> <span class="string">master</span></span><br><span class="line"></span><br></pre></td></tr></table></figure>
</li>
<li><p>修改好返回我们的 terminal，在 Blog 目录下做如下操作：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"># 在当前目录下</span><br><span class="line">$ npm install hexo-deployer-git --save</span><br><span class="line"># 清除 build files</span><br><span class="line">$ hexo clean</span><br><span class="line"># 产生静态网页</span><br><span class="line">$ hexo g</span><br><span class="line"># 部署到Gitee page上</span><br><span class="line">$ hexo d</span><br></pre></td></tr></table></figure>
</li>
<li><p>操作成功后，打开码云上的仓库，应该可以看到我们上传上去的文件了，接下来再点击页面上的 “服务”，你应该会到看 “Gitee Pages” 这个选项了，点击它，翻到页面底部，点击部署，等待码云部署完成，就可以访问了。</p>
</li>
</ol>
<h4 id="发布第一篇文章"><a href="#发布第一篇文章" class="headerlink" title="发布第一篇文章"></a>发布第一篇文章</h4><ol>
<li><p><code>cd</code> 到 <code>Blog</code> 文件夹，使用 <code>hexo new &quot;文章题目&quot;</code> 生成一篇新的文章。在 Blog -&gt; source -&gt; _posts 目录中打开新生成的文章，发现已经自动生成好了必要前缀。</p>
<figure class="highlight markdown"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">---</span><br><span class="line">title: macOS Hexo + Gitee 安装 &amp; 使用 详细攻略</span><br><span class="line">date: 2020-01-18 19:01:36</span><br><span class="line">tags: </span><br><span class="line">---</span><br></pre></td></tr></table></figure>

<blockquote>
<p>对于默认存在的 Hello World 测试博文，可以打开 Blog 文件夹，找到 source -&gt; _posts 文件夹，里面发现有一个默认的 hello-world.md 文件，这就是我们第一次打开时看到的博文，可以将它删除。</p>
</blockquote>
</li>
<li><p>写入博文后保存，我们回到 Terminal 切换到 Blog 目录，执行 <code>hexo clean &amp;&amp; hexo g -d</code> 发布，到此，发布成功！</p>
<blockquote>
<p>但是发布成功后刷新域名你并不能立即看到，因为普通版的 gitee pages 不支持推送后立即部署，还需要到 <strong>仓库 -&gt; 服务 -&gt; Gitee Pages</strong> 进去点击 <strong>更新</strong>，等待重新部署后重新刷新域名应该就可以看到你发布的文章了！</p>
</blockquote>
</li>
</ol>
<h4 id="添加图片"><a href="#添加图片" class="headerlink" title="添加图片"></a>添加图片</h4><p>我们用一个插件来非常简单的实现 markdown 语法添加图片。</p>
<ol>
<li><p>Blog 目录安装图片插件</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ npm install hexo-asset-image --save</span><br></pre></td></tr></table></figure>
</li>
<li><p>修改 <code>_config.yml</code> 文件 <code>post_asset_folder: false</code> 的值为 <code>true</code>。</p>
</li>
<li><p><code>new</code> 一篇新文章 <code>hexo new ceshi</code>，会发现在 Blog -&gt; source -&gt; _posts 下生成了一个 ceshi 的文件夹，我们只需要将图片放进去，比如放进去一个 cat.jpg。</p>
</li>
<li><p>在 ceshi.md 中直接写 <code>![cat](cat.jpg)</code> 这张图片发布后就直接能够看了 (但是你在编辑过程中是看不到的)。</p>
</li>
</ol>
<blockquote>
<p>1.0 版本的插件有缺陷，会导致生成的图片链接有误，打开 “Blog/node_modules/hexo-asset-image/index.js”, 用如下代码替换掉里面所有内容。(或直接替换成修改好的插件 <code>npm install https://github.com/7ym0n/hexo-asset-image --save</code>)</p>
</blockquote>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">&#x27;use strict&#x27;</span>;</span><br><span class="line"><span class="keyword">var</span> cheerio = <span class="built_in">require</span>(<span class="string">&#x27;cheerio&#x27;</span>);</span><br><span class="line"></span><br><span class="line"><span class="comment">// http://stackoverflow.com/questions/14480345/how-to-get-the-nth-occurrence-in-a-string</span></span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">getPosition</span>(<span class="params">str, m, i</span>) </span>&#123;</span><br><span class="line">  <span class="keyword">return</span> str.split(m, i).join(m).length;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="keyword">var</span> version = <span class="built_in">String</span>(hexo.version).split(<span class="string">&#x27;.&#x27;</span>);</span><br><span class="line">hexo.extend.filter.register(<span class="string">&#x27;after_post_render&#x27;</span>, <span class="function"><span class="keyword">function</span> (<span class="params">data</span>) </span>&#123;</span><br><span class="line">  <span class="keyword">var</span> config = hexo.config;</span><br><span class="line">  <span class="keyword">if</span> (config.post_asset_folder) &#123;</span><br><span class="line">    <span class="keyword">var</span> link = data.permalink;</span><br><span class="line">    <span class="keyword">if</span> (version.length &gt; <span class="number">0</span> &amp;&amp; <span class="built_in">Number</span>(version[<span class="number">0</span>]) == <span class="number">3</span>)</span><br><span class="line">      <span class="keyword">var</span> beginPos = getPosition(link, <span class="string">&#x27;/&#x27;</span>, <span class="number">1</span>) + <span class="number">1</span>;</span><br><span class="line">    <span class="keyword">else</span></span><br><span class="line">      <span class="keyword">var</span> beginPos = getPosition(link, <span class="string">&#x27;/&#x27;</span>, <span class="number">3</span>) + <span class="number">1</span>;</span><br><span class="line">    <span class="comment">// In hexo 3.1.1, the permalink of &quot;about&quot; page is like &quot;.../about/index.html&quot;.</span></span><br><span class="line">    <span class="keyword">var</span> endPos = link.lastIndexOf(<span class="string">&#x27;/&#x27;</span>) + <span class="number">1</span>;</span><br><span class="line">    link = link.substring(beginPos, endPos);</span><br><span class="line"></span><br><span class="line">    <span class="keyword">var</span> toprocess = [<span class="string">&#x27;excerpt&#x27;</span>, <span class="string">&#x27;more&#x27;</span>, <span class="string">&#x27;content&#x27;</span>];</span><br><span class="line">    <span class="keyword">for</span> (<span class="keyword">var</span> i = <span class="number">0</span>; i &lt; toprocess.length; i++) &#123;</span><br><span class="line">      <span class="keyword">var</span> key = toprocess[i];</span><br><span class="line"></span><br><span class="line">      <span class="keyword">var</span> $ = cheerio.load(data[key], &#123;</span><br><span class="line">        ignoreWhitespace: <span class="literal">false</span>,</span><br><span class="line">        xmlMode: <span class="literal">false</span>,</span><br><span class="line">        lowerCaseTags: <span class="literal">false</span>,</span><br><span class="line">        decodeEntities: <span class="literal">false</span></span><br><span class="line">      &#125;);</span><br><span class="line"></span><br><span class="line">      $(<span class="string">&#x27;img&#x27;</span>).each(<span class="function"><span class="keyword">function</span> (<span class="params"></span>) </span>&#123;</span><br><span class="line">        <span class="keyword">if</span> ($(<span class="built_in">this</span>).attr(<span class="string">&#x27;src&#x27;</span>)) &#123;</span><br><span class="line">          <span class="comment">// For windows style path, we replace &#x27;\&#x27; to &#x27;/&#x27;.</span></span><br><span class="line">          <span class="keyword">var</span> src = $(<span class="built_in">this</span>).attr(<span class="string">&#x27;src&#x27;</span>).replace(<span class="string">&#x27;\\&#x27;</span>, <span class="string">&#x27;/&#x27;</span>);</span><br><span class="line">          <span class="keyword">if</span> (!<span class="regexp">/http[s]*.*|\/\/.*/</span>.test(src) &amp;&amp;</span><br><span class="line">            !<span class="regexp">/^\s*\//</span>.test(src)) &#123;</span><br><span class="line">            <span class="comment">// For &quot;about&quot; page, the first part of &quot;src&quot; can&#x27;t be removed.</span></span><br><span class="line">            <span class="comment">// In addition, to support multi-level local directory.</span></span><br><span class="line">            <span class="keyword">var</span> linkArray = link.split(<span class="string">&#x27;/&#x27;</span>).filter(<span class="function"><span class="keyword">function</span> (<span class="params">elem</span>) </span>&#123;</span><br><span class="line">              <span class="keyword">return</span> elem != <span class="string">&#x27;&#x27;</span>;</span><br><span class="line">            &#125;);</span><br><span class="line">            <span class="keyword">var</span> srcArray = src.split(<span class="string">&#x27;/&#x27;</span>).filter(<span class="function"><span class="keyword">function</span> (<span class="params">elem</span>) </span>&#123;</span><br><span class="line">              <span class="keyword">return</span> elem != <span class="string">&#x27;&#x27;</span> &amp;&amp; elem != <span class="string">&#x27;.&#x27;</span>;</span><br><span class="line">            &#125;);</span><br><span class="line">            <span class="keyword">if</span> (srcArray.length &gt; <span class="number">1</span>)</span><br><span class="line">              srcArray.shift();</span><br><span class="line">            src = srcArray.join(<span class="string">&#x27;/&#x27;</span>);</span><br><span class="line">            $(<span class="built_in">this</span>).attr(<span class="string">&#x27;src&#x27;</span>, config.root + link + src);</span><br><span class="line">            <span class="built_in">console</span>.info &amp;&amp; <span class="built_in">console</span>.info(<span class="string">&quot;update link as:--&gt;&quot;</span> + config.root + link + src);</span><br><span class="line">          &#125;</span><br><span class="line">        &#125; <span class="keyword">else</span> &#123;</span><br><span class="line">          <span class="built_in">console</span>.info &amp;&amp; <span class="built_in">console</span>.info(<span class="string">&quot;no src attr, skipped...&quot;</span>);</span><br><span class="line">          <span class="built_in">console</span>.info &amp;&amp; <span class="built_in">console</span>.info($(<span class="built_in">this</span>));</span><br><span class="line">        &#125;</span><br><span class="line">      &#125;);</span><br><span class="line">      data[key] = $.html();</span><br><span class="line">    &#125;</span><br><span class="line">  &#125;</span><br><span class="line">&#125;);</span><br></pre></td></tr></table></figure>
<p><img src="/2020/01/18/Mac-Hexo-Gitee-%E5%AE%89%E8%A3%85-%E4%BD%BF%E7%94%A8-%E5%85%A8%E8%AE%B0%E5%BD%95/cat.jpg" alt="cat"></p>
<h4 id="主题美化"><a href="#主题美化" class="headerlink" title="主题美化"></a>主题美化</h4><p>我当前博客的主题已更改为 Ayer，主题非常美观，且提供的工具和内容非常全面，喜欢这款风格主题可以访问 <a target="_blank" rel="noopener" href="https://shen-yu.gitee.io/2019/ayer/">Ayer中文说明</a>进行配置，谢谢作者<a target="_blank" rel="noopener" href="https://shen-yu.gitee.io/">@沈宇</a>。</p>
<p><img src="/2020/01/18/Mac-Hexo-Gitee-%E5%AE%89%E8%A3%85-%E4%BD%BF%E7%94%A8-%E5%85%A8%E8%AE%B0%E5%BD%95/hexo-theme-ayer.png" alt="hexo-theme-ayer"></p>
<blockquote>
<p>这里记录一个之前使用的主题，但是作者已经不再提供支持了，版本较老可能不支持新版本的 Node 和 Hexo，但是主题还是很清新的，喜欢的也可以试下。</p>
</blockquote>
<blockquote>
<p><strong>Material Theme</strong> 的安装和使用过程。</p>
</blockquote>
<blockquote>
<ol>
<li>前往 <a target="_blank" rel="noopener" href="https://github.com/bolnh/hexo-theme-material/releases">Release</a> 页面下载 1.5.2 版本的 SourceCode(zip)，目前 1.5.6 版本的主题好像有问题。</li>
<li>解压后重命名 文件夹 为 “material”</li>
<li>把 material 目录放到 Blog -&gt; themes 目录下与  landscape 同级，打开 material 目录，如果你看到只有 “_config.template.yml” 文件，那么你还需要复制一份把它命名为 “_config.yml”。</li>
<li>修改 Blog 目录下的 “_config.yml” 文件</li>
</ol>
</blockquote>
<blockquote>
  <figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># Extensions</span></span><br><span class="line"><span class="comment">## Plugins: https://hexo.io/plugins/</span></span><br><span class="line"><span class="comment">## Themes: https://hexo.io/themes/</span></span><br><span class="line"><span class="attr">theme:</span> <span class="string">material</span></span><br></pre></td></tr></table></figure>

<ol start="5">
<li><p><code>hexo g &amp;&amp; hexo s</code> 然后访问 <a target="_blank" rel="noopener" href="http://localhost:4000/">http://localhost:4000</a> 检查一下新主题是否已经良好运行。</p>
<blockquote>
<p>这里记录一个出现在 1.5.6 版本上的一个问题，打开网页后直接白屏，其实如果单步运行 <code>hexo g</code> 后 Terminal 就已经报错 “Cannot read property ‘startsWith’ of null”，原因在于没有对配置做基本&gt; 的检查。事实上里面很多配置只要任意少一些都会直接炸，没有做任何的默认选项，要解决这个问题需要到主题文件夹修改 ayout/_widget/dnsprefetch.ejs 文件内容如下：</p>
</blockquote>
</li>
</ol>
</blockquote>
<blockquote>
<blockquote>
   <figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">&lt;% &#125; <span class="keyword">else</span> <span class="keyword">if</span>(theme.comment.use.startsWith(<span class="string">&quot;disqus&quot;</span>)) &#123; %&gt;</span><br><span class="line"><span class="comment">// to</span></span><br><span class="line">&lt;% &#125; <span class="keyword">else</span> <span class="keyword">if</span>(theme.comment.use &amp;&amp; theme.comment.use.startsWith(<span class="string">&quot;disqus&quot;</span>)) &#123; %&gt;</span><br></pre></td></tr></table></figure>
<ol start="6">
<li><code>hexo clean &amp;&amp; hexo g -d</code> 成功后通过 Gitee Pages 刷新。</li>
</ol>
</blockquote>
</blockquote>
<blockquote>
<blockquote>
<p>主题还有很多配置需要在主题目录下的 _config.yml 修改各个参数，这也是我接下来要做的，在这就不把篇幅拉的过长了。</p>
</blockquote>
</blockquote>
<h5 id="代码高亮"><a href="#代码高亮" class="headerlink" title="代码高亮"></a>代码高亮</h5><p>如果没有代码高亮显示，则需要修改 Blog 目录下 _config.yml 文件：</p>
<figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="attr">highlight:</span></span><br><span class="line">  <span class="attr">enable:</span> <span class="literal">false</span></span><br><span class="line">  <span class="attr">line_number:</span> <span class="literal">true</span></span><br><span class="line">  <span class="attr">auto_detect:</span> <span class="literal">false</span></span><br><span class="line">  <span class="attr">tab_replace:</span> <span class="string">&#x27;&#x27;</span></span><br><span class="line">  <span class="attr">wrap:</span> <span class="literal">true</span></span><br><span class="line">  <span class="attr">hljs:</span> <span class="literal">false</span></span><br></pre></td></tr></table></figure>
<blockquote>
<p>如果使用<strong>Material</strong>主题还需要：</p>
</blockquote>
<blockquote>
<p>然后到 Blog/themes/material 目录下修改 _config.yml:</p>
</blockquote>
<blockquote>
<figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># Code highlight</span></span><br><span class="line"><span class="comment"># You can only enable one of them to avoid issues.</span></span><br><span class="line"><span class="comment"># Also you need to disable highlight option in hexo&#x27;s _config.yml.</span></span><br><span class="line"><span class="comment">#</span></span><br><span class="line"><span class="comment">#    Prettify</span></span><br><span class="line"><span class="comment">#        theme: # Available value in /source/css/prettify/[theme].min.css</span></span><br><span class="line"><span class="attr">prettify:</span></span><br><span class="line">    <span class="attr">enable:</span> <span class="literal">true</span></span><br><span class="line">    <span class="attr">theme:</span> <span class="string">&quot;github-v2&quot;</span></span><br></pre></td></tr></table></figure>
</blockquote>
<h5 id="分类"><a href="#分类" class="headerlink" title="分类"></a>分类</h5><p>Ayer 主题参考配置页面</p>
<blockquote>
<p>Material 原主题是带有分类页面的，只不过默认关闭，我们可以手动打开。</p>
</blockquote>
<blockquote>
<ol>
<li>我们到 Blog/themes/material 目录中修改 _config.yml 文件，打开关于 “categories” 的设置</li>
</ol>
</blockquote>
<blockquote>
  <figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"># Sidebar Customize</span><br><span class="line">sidebar:</span><br><span class="line">    ...</span><br><span class="line">    categories:</span><br><span class="line">        use: true</span><br><span class="line">        icon: chrome_reader_mode</span><br><span class="line">        divider: false</span><br><span class="line">    ...</span><br></pre></td></tr></table></figure>

<ol start="2">
<li><p>给文章添加分类的时候，多添加一行标记 <code>categories</code> 就好了：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">---</span><br><span class="line">title: Mac Hexo + Gitee 安装 &amp; 使用 全记录</span><br><span class="line">date: 2020-01-18 23:06:08</span><br><span class="line">categories:</span><br><span class="line">- 深度应用</span><br><span class="line">---</span><br></pre></td></tr></table></figure>
</li>
</ol>
</blockquote>
<h5 id="关于"><a href="#关于" class="headerlink" title="关于"></a>关于</h5><ol>
<li><p>创建页面</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ hexo new page about</span><br></pre></td></tr></table></figure>
</li>
<li><p>修改 Blog/themes/material 目录中的 _config.yml 文件，“pages” 增加关于 “about” 的配置</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"># Sidebar Customize</span><br><span class="line">sidebar:</span><br><span class="line">    ...</span><br><span class="line">    pages:</span><br><span class="line">       关于:</span><br><span class="line">          link: &quot;&#x2F;about&quot;</span><br><span class="line">          icon: person</span><br><span class="line">          divider: false</span><br><span class="line">    ...</span><br></pre></td></tr></table></figure></li>
<li><p>保存并运行就可以看到 slidebar 上新配置的关于了，但是页面是空的，怎么展示需要修改 Blog/source 目录下生成一个 about 的目录下的 “index.md” 文件了。</p>
</li>
</ol>
<h4 id="本地搜索"><a href="#本地搜索" class="headerlink" title="本地搜索"></a>本地搜索</h4><p>使用本地搜索需要安装 “hexo-generator-search” 插件</p>
<ol>
<li><p>在 Blog 目录下执行</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ npm install hexo-generator-search --save</span><br></pre></td></tr></table></figure>
</li>
<li><p>修改 Blog/_config.yml 文件，最后增加如下代码</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"># Search</span><br><span class="line"># URL: https:&#x2F;&#x2F;github.com&#x2F;wzpan&#x2F;hexo-generator-search</span><br><span class="line">search:</span><br><span class="line">  path: search.xml</span><br><span class="line">  field: post</span><br><span class="line">  content: true</span><br></pre></td></tr></table></figure>

</li>
</ol>
<h3 id="参考资料"><a href="#参考资料" class="headerlink" title="参考资料"></a>参考资料</h3><blockquote>
<p><a target="_blank" rel="noopener" href="https://hexo.io/docs/">hexo.io</a><br><a target="_blank" rel="noopener" href="https://gitee.com/help/articles/4136">码云帮助中心</a><br><a target="_blank" rel="noopener" href="https://www.jianshu.com/p/e0275f8f089e">mac更新npm和node</a><br><a target="_blank" rel="noopener" href="https://www.jianshu.com/p/77db3862595c">Mac 系统下搭建hexo个人博客</a><br><a target="_blank" rel="noopener" href="https://www.jianshu.com/p/5014133ba61a">使用Gitee+Hexo搭建个人博客</a><br><a target="_blank" rel="noopener" href="https://blog.csdn.net/qq_29401491/article/details/79830282">MacOS安装homebrew搭建Git环境</a><br><a target="_blank" rel="noopener" href="https://blog.csdn.net/whjkm/article/details/81088518">Hexo版本升级和Next主题升级之坑</a><br><a target="_blank" rel="noopener" href="https://blog.csdn.net/a_bet_of_three_years/article/details/82120393">npm install 报错不存在package.json</a><br><a target="_blank" rel="noopener" href="https://stackoverflow.com/questions/16073603/how-do-i-update-each-dependency-in-package-json-to-the-latest-version/22849716#22849716">How do I update each dependency in package.json to the latest version?</a><br><a target="_blank" rel="noopener" href="https://www.jianshu.com/p/e17711e44e00">Hexo使用攻略-添加分类及标签</a><br><a target="_blank" rel="noopener" href="https://www.jianshu.com/p/b4cb42d2d48e">Hexo 使用 hexo-theme-material 实现酷炫的页面效果</a><br><a target="_blank" rel="noopener" href="https://github.com/bolnh/hexo-theme-material">bolnh/hexo-theme-material</a><br><a target="_blank" rel="noopener" href="https://blog.csdn.net/qq_45262739/article/details/95056218">静态博客 Hexo material 主题安装</a><br><a target="_blank" rel="noopener" href="https://github.com/bolnh/hexo-theme-material/issues/686#issuecomment-410617760">hexo s 依旧报错。 #686</a><br><a target="_blank" rel="noopener" href="https://blog.csdn.net/u010996565/article/details/89196612">【Hexo】hexo在文章中添加图片</a><br><a target="_blank" rel="noopener" href="https://www.jianshu.com/p/3db6a61d3782">hexo使用markdown图片无法显示问题</a><br><a target="_blank" rel="noopener" href="https://blog.csdn.net/u011240016/article/details/79422448">next主题设定代码高亮格式</a></p>
</blockquote>
 
      <!-- reward -->
      
      <div id="reword-out">
        <div id="reward-btn">
          打赏
        </div>
      </div>
      
    </div>
    

    <!-- copyright -->
    
    <div class="declare">
      <ul class="post-copyright">
        <li>
          <i class="ri-copyright-line"></i>
          <strong>版权声明： </strong>
          
          本博客所有文章除特别声明外，著作权归作者所有。转载请注明出处！
          
        </li>
      </ul>
    </div>
    
    <footer class="article-footer">
       
<div class="share-btn">
      <span class="share-sns share-outer">
        <i class="ri-share-forward-line"></i>
        分享
      </span>
      <div class="share-wrap">
        <i class="arrow"></i>
        <div class="share-icons">
          
          <a class="weibo share-sns" href="javascript:;" data-type="weibo">
            <i class="ri-weibo-fill"></i>
          </a>
          <a class="weixin share-sns wxFab" href="javascript:;" data-type="weixin">
            <i class="ri-wechat-fill"></i>
          </a>
          <a class="qq share-sns" href="javascript:;" data-type="qq">
            <i class="ri-qq-fill"></i>
          </a>
          <a class="douban share-sns" href="javascript:;" data-type="douban">
            <i class="ri-douban-line"></i>
          </a>
          <!-- <a class="qzone share-sns" href="javascript:;" data-type="qzone">
            <i class="icon icon-qzone"></i>
          </a> -->
          
          <a class="facebook share-sns" href="javascript:;" data-type="facebook">
            <i class="ri-facebook-circle-fill"></i>
          </a>
          <a class="twitter share-sns" href="javascript:;" data-type="twitter">
            <i class="ri-twitter-fill"></i>
          </a>
          <a class="google share-sns" href="javascript:;" data-type="google">
            <i class="ri-google-fill"></i>
          </a>
        </div>
      </div>
</div>

<div class="wx-share-modal">
    <a class="modal-close" href="javascript:;"><i class="ri-close-circle-line"></i></a>
    <p>扫一扫，分享到微信</p>
    <div class="wx-qrcode">
      <img src="//api.qrserver.com/v1/create-qr-code/?size=150x150&data=https://zesicus.gitee.io/2020/01/18/Mac-Hexo-Gitee-%E5%AE%89%E8%A3%85-%E4%BD%BF%E7%94%A8-%E5%85%A8%E8%AE%B0%E5%BD%95/" alt="微信分享二维码">
    </div>
</div>

<div id="share-mask"></div>  
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/Blog/" rel="tag">Blog</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/Gitee/" rel="tag">Gitee</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/Hexo/" rel="tag">Hexo</a></li></ul>

    </footer>
  </div>

   
  <nav class="article-nav">
    
      <a href="/2020/01/20/Mac-%E8%8E%B7%E5%8F%96%E6%96%87%E4%BB%B6%E5%A4%B9%E5%A4%A7%E5%B0%8F/" class="article-nav-link">
        <strong class="article-nav-caption">上一篇</strong>
        <div class="article-nav-title">
          
            Mac 终端获取当前文件夹大小
          
        </div>
      </a>
    
    
  </nav>

   
<!-- valine评论 -->
<div id="vcomments-box">
  <div id="vcomments"></div>
</div>
<script src="//cdn1.lncld.net/static/js/3.0.4/av-min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/valine@1.4.14/dist/Valine.min.js"></script>
<script>
  new Valine({
    el: "#vcomments",
    app_id: "M5MxuHVy9KSi3HL3TynyJ7Wx-gzGzoHsz",
    app_key: "R1KGWG7s6ISWPXYKvbmjyNka",
    path: window.location.pathname,
    avatar: "monsterid",
    placeholder: "给我的文章加点评论吧~",
    recordIP: true,
  });
  const infoEle = document.querySelector("#vcomments .info");
  if (infoEle && infoEle.childNodes && infoEle.childNodes.length > 0) {
    infoEle.childNodes.forEach(function (item) {
      item.parentNode.removeChild(item);
    });
  }
</script>
<style>
  #vcomments-box {
    padding: 5px 30px;
  }

  @media screen and (max-width: 800px) {
    #vcomments-box {
      padding: 5px 0px;
    }
  }

  #vcomments-box #vcomments {
    background-color: #fff;
  }

  .v .vlist .vcard .vh {
    padding-right: 20px;
  }

  .v .vlist .vcard {
    padding-left: 10px;
  }
</style>

 
   
     
</article>

</section>
      <footer class="footer">
  <div class="outer">
    <ul>
      <li>
        Copyrights &copy;
        2020-2021
        <i class="ri-heart-fill heart_icon"></i> Decline
      </li>
    </ul>
    <ul>
      <li>
        
        
        
        由 <a href="https://hexo.io" target="_blank">Hexo</a> 强力驱动
        <span class="division">|</span>
        主题 - <a href="https://github.com/Shen-Yu/hexo-theme-ayer" target="_blank">Ayer</a>
        
      </li>
    </ul>
    <ul>
      <li>
        
        
        <span>
  <span><i class="ri-user-3-fill"></i>访问人数:<span id="busuanzi_value_site_uv"></span></s>
  <span class="division">|</span>
  <span><i class="ri-eye-fill"></i>浏览次数:<span id="busuanzi_value_page_pv"></span></span>
</span>
        
      </li>
    </ul>
    <ul>
      
    </ul>
    <ul>
      
    </ul>
    <ul>
      <li>
        <!-- cnzz统计 -->
        
        <script type="text/javascript" src='https://v1.cnzz.com/z_stat.php?id=1279621682&amp;web_id=1279621682'></script>
        
      </li>
    </ul>
  </div>
</footer>
      <div class="float_btns">
        <div class="totop" id="totop">
  <i class="ri-arrow-up-line"></i>
</div>

<div class="todark" id="todark">
  <i class="ri-moon-line"></i>
</div>

      </div>
    </main>
    <aside class="sidebar on">
      <button class="navbar-toggle"></button>
<nav class="navbar">
  
  <div class="logo">
    <a href="/"><img src="/images/logoicon.png" alt="黑森林"></a>
  </div>
  
  <ul class="nav nav-main">
    
    <li class="nav-item">
      <a class="nav-item-link" href="/">主页</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/archives">归档</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/categories">分类</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/tags">标签</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/friends">友链</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/about">关于我</a>
    </li>
    
  </ul>
</nav>
<nav class="navbar navbar-bottom">
  <ul class="nav">
    <li class="nav-item">
      
      <a class="nav-item-link nav-item-search"  title="搜索">
        <i class="ri-search-line"></i>
      </a>
      
      
      <a class="nav-item-link" target="_blank" href="/atom.xml" title="RSS Feed">
        <i class="ri-rss-line"></i>
      </a>
      
    </li>
  </ul>
</nav>
<div class="search-form-wrap">
  <div class="local-search local-search-plugin">
  <input type="search" id="local-search-input" class="local-search-input" placeholder="Search...">
  <div id="local-search-result" class="local-search-result"></div>
</div>
</div>
    </aside>
    <script>
      if (window.matchMedia("(max-width: 768px)").matches) {
        document.querySelector('.content').classList.remove('on');
        document.querySelector('.sidebar').classList.remove('on');
      }
    </script>
    <div id="mask"></div>

<!-- #reward -->
<div id="reward">
  <span class="close"><i class="ri-close-line"></i></span>
  <p class="reward-p"><i class="ri-cup-line"></i>请我喝杯咖啡吧~</p>
  <div class="reward-box">
    
    <div class="reward-item">
      <img class="reward-img" src="/images/ali.jpeg">
      <span class="reward-type">支付宝</span>
    </div>
    
    
    <div class="reward-item">
      <img class="reward-img" src="/images/wx.png">
      <span class="reward-type">微信</span>
    </div>
    
  </div>
</div>
    
<script src="/js/jquery-2.0.3.min.js"></script>


<script src="/js/lazyload.min.js"></script>

<!-- Tocbot -->


<script src="/js/tocbot.min.js"></script>

<script>
  tocbot.init({
    tocSelector: '.tocbot',
    contentSelector: '.article-entry',
    headingSelector: 'h1, h2, h3, h4, h5, h6',
    hasInnerContainers: true,
    scrollSmooth: true,
    scrollContainer: 'main',
    positionFixedSelector: '.tocbot',
    positionFixedClass: 'is-position-fixed',
    fixedSidebarOffset: 'auto'
  });
</script>

<script src="https://cdn.jsdelivr.net/npm/jquery-modal@0.9.2/jquery.modal.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/jquery-modal@0.9.2/jquery.modal.min.css">
<script src="https://cdn.jsdelivr.net/npm/justifiedGallery@3.7.0/dist/js/jquery.justifiedGallery.min.js"></script>

<script src="/dist/main.js"></script>

<!-- ImageViewer -->

<!-- Root element of PhotoSwipe. Must have class pswp. -->
<div class="pswp" tabindex="-1" role="dialog" aria-hidden="true">

    <!-- Background of PhotoSwipe. 
         It's a separate element as animating opacity is faster than rgba(). -->
    <div class="pswp__bg"></div>

    <!-- Slides wrapper with overflow:hidden. -->
    <div class="pswp__scroll-wrap">

        <!-- Container that holds slides. 
            PhotoSwipe keeps only 3 of them in the DOM to save memory.
            Don't modify these 3 pswp__item elements, data is added later on. -->
        <div class="pswp__container">
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
        </div>

        <!-- Default (PhotoSwipeUI_Default) interface on top of sliding area. Can be changed. -->
        <div class="pswp__ui pswp__ui--hidden">

            <div class="pswp__top-bar">

                <!--  Controls are self-explanatory. Order can be changed. -->

                <div class="pswp__counter"></div>

                <button class="pswp__button pswp__button--close" title="Close (Esc)"></button>

                <button class="pswp__button pswp__button--share" style="display:none" title="Share"></button>

                <button class="pswp__button pswp__button--fs" title="Toggle fullscreen"></button>

                <button class="pswp__button pswp__button--zoom" title="Zoom in/out"></button>

                <!-- Preloader demo http://codepen.io/dimsemenov/pen/yyBWoR -->
                <!-- element will get class pswp__preloader--active when preloader is running -->
                <div class="pswp__preloader">
                    <div class="pswp__preloader__icn">
                        <div class="pswp__preloader__cut">
                            <div class="pswp__preloader__donut"></div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="pswp__share-modal pswp__share-modal--hidden pswp__single-tap">
                <div class="pswp__share-tooltip"></div>
            </div>

            <button class="pswp__button pswp__button--arrow--left" title="Previous (arrow left)">
            </button>

            <button class="pswp__button pswp__button--arrow--right" title="Next (arrow right)">
            </button>

            <div class="pswp__caption">
                <div class="pswp__caption__center"></div>
            </div>

        </div>

    </div>

</div>

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe.min.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/default-skin/default-skin.min.css">
<script src="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe-ui-default.min.js"></script>

<script>
    function viewer_init() {
        let pswpElement = document.querySelectorAll('.pswp')[0];
        let $imgArr = document.querySelectorAll(('.article-entry img:not(.reward-img)'))

        $imgArr.forEach(($em, i) => {
            $em.onclick = () => {
                // slider展开状态
                // todo: 这样不好，后面改成状态
                if (document.querySelector('.left-col.show')) return
                let items = []
                $imgArr.forEach(($em2, i2) => {
                    let img = $em2.getAttribute('data-idx', i2)
                    let src = $em2.getAttribute('data-target') || $em2.getAttribute('src')
                    let title = $em2.getAttribute('alt')
                    // 获得原图尺寸
                    const image = new Image()
                    image.src = src
                    items.push({
                        src: src,
                        w: image.width || $em2.width,
                        h: image.height || $em2.height,
                        title: title
                    })
                })
                var gallery = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, items, {
                    index: parseInt(i)
                });
                gallery.init()
            }
        })
    }
    viewer_init()
</script>

<!-- MathJax -->

<!-- Katex -->

<!-- busuanzi  -->


<script src="/js/busuanzi-2.3.pure.min.js"></script>


<!-- ClickLove -->

<!-- ClickBoom1 -->

<!-- ClickBoom2 -->

<!-- CodeCopy -->


<link rel="stylesheet" href="/css/clipboard.css">

<script src="https://cdn.jsdelivr.net/npm/clipboard@2/dist/clipboard.min.js"></script>
<script>
  function wait(callback, seconds) {
    var timelag = null;
    timelag = window.setTimeout(callback, seconds);
  }
  !function (e, t, a) {
    var initCopyCode = function(){
      var copyHtml = '';
      copyHtml += '<button class="btn-copy" data-clipboard-snippet="">';
      copyHtml += '<i class="ri-file-copy-2-line"></i><span>COPY</span>';
      copyHtml += '</button>';
      $(".highlight .code pre").before(copyHtml);
      $(".article pre code").before(copyHtml);
      var clipboard = new ClipboardJS('.btn-copy', {
        target: function(trigger) {
          return trigger.nextElementSibling;
        }
      });
      clipboard.on('success', function(e) {
        let $btn = $(e.trigger);
        $btn.addClass('copied');
        let $icon = $($btn.find('i'));
        $icon.removeClass('ri-file-copy-2-line');
        $icon.addClass('ri-checkbox-circle-line');
        let $span = $($btn.find('span'));
        $span[0].innerText = 'COPIED';
        
        wait(function () { // 等待两秒钟后恢复
          $icon.removeClass('ri-checkbox-circle-line');
          $icon.addClass('ri-file-copy-2-line');
          $span[0].innerText = 'COPY';
        }, 2000);
      });
      clipboard.on('error', function(e) {
        e.clearSelection();
        let $btn = $(e.trigger);
        $btn.addClass('copy-failed');
        let $icon = $($btn.find('i'));
        $icon.removeClass('ri-file-copy-2-line');
        $icon.addClass('ri-time-line');
        let $span = $($btn.find('span'));
        $span[0].innerText = 'COPY FAILED';
        
        wait(function () { // 等待两秒钟后恢复
          $icon.removeClass('ri-time-line');
          $icon.addClass('ri-file-copy-2-line');
          $span[0].innerText = 'COPY';
        }, 2000);
      });
    }
    initCopyCode();
  }(window, document);
</script>


<!-- CanvasBackground -->


<script src="/js/dz.js"></script>



    
  </div>
</body>

</html>